diff --git a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp
index a30b452..d45f3ff 100644
--- a/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp
+++ b/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp
@@ -2451,6 +2451,12 @@ int OGR2SQLITE_static_register (sqlite3 * hDB, char **pzErrMsg,
 /*                           OGR2SQLITE_Register()                      */
 /************************************************************************/
 
+#ifdef sqlite3_auto_extension
+// Sqlite 3.8.7 defines sqlite3_auto_extension via sqlite3_api
+// which is not initialized at this moment
+#undef sqlite3_auto_extension
+#endif
+
 /* We call this function so that each time a db is created, */
 /* OGR2SQLITE_static_register is called, to initialize the sqlite3_api */
 /* structure with the right pointers. */
